package 树;

import binary_tree.TreeNode;

/**
 * 返回所有 左节点之和
 * @author macy
 * @date 2025/11/10 16:48
 */
public class TreeNodeSumOfLeft {


    int sum=0;
    public static void main(String[] args) {

    }



    public int sumOfLeftLeaves(TreeNode root) {
        if(root==null){
            return 0;
        }


        sum=sumOfLeftLeaves(root.left)+sumOfLeftLeaves(root.right);
        if(root.left !=null && root.left.left==null && root.left.right==null){
            sum+=root.left.val;
        }
        return sum;
    }


}
